Skip to content

Conversation

@jianminzhao
Copy link
Contributor

When parsing a query in SQL++, we log a warning if an (unquoted) identifier is reserved in the server.

When parsing a query in SQL++, we log a warning if an (unquoted) identifier is reserved in the server.
@cbl-bot
Copy link

cbl-bot commented Nov 20, 2025

Code Coverage Results:

Type Percentage
branches 65.86
functions 78.14
instantiations 71.66
lines 77.15
regions 73.5

}

constexpr const char* kServerReservedWords =
"ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove ADVISE ALTER ANALYZE BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CLUSTER


constexpr const char* kServerReservedWords =
"ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER "
"COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove COLLECTION COMMIT COMMITTED CONNECT CONTINUE CREATE

constexpr const char* kServerReservedWords =
"ADVISE ALL ALTER ANALYZE ARRAY AT BEGIN BINARY BOOLEAN BREAK BUCKET BUILD CACHE CALL CAST CLUSTER "
"COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT"
" CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove CYCLE DATABASE DATASET DATASTORE DECLARE DELETE DROP

"COLLECTION COMMIT COMMITTED CONNECT CONTINUE CORRELATED COVER CREATE CURRENT"
" CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT "
"ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS"
" FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove FLUSH FTS GOLANG GSI

" CYCLE DATABASE DATASET DATASTORE DECLARE DECREMENT DEFAULT DELETE DERIVED DESCRIBE DO DROP EACH ELEMENT "
"ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS"
" FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT "
"INDEX INFER INLINE INSERT INTERSECT INTO ISOLATION JAVASCRIPT KEY"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove INSERT INTO JAVASCRIPT

"ESCAPE EXCEPT EXCLUDE EXECUTE EXISTS EXPLAIN FETCH FILTER FIRST FLATTEN FLATTEN_KEYS"
" FLUSH FOLLOWING FOR FORCE FTS FUNCTION GOLANG GRANT GROUPS GSI HASH IF IGNORE ILIKE INCLUDE INCREMENT "
"INDEX INFER INLINE INSERT INTERSECT INTO ISOLATION JAVASCRIPT KEY"
" KEYS KEYSPACE KNOWN LANGUAGE LAST LATERAL LET LETTING LEVEL LSM MAP MAPPING MATCHED MATERIALIZED "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove LANGUAGE

"PRECEDING PREPARE PREV PREVIOUS PREVVAL PRIMARY PRIVATE PRIVILEGE PROBE PROCEDURE PUBLIC"
" RANGE RAW READ REALM RECURSIVE REDUCE RENAME REPLACE RESPECT RESTART RESTRICT RETURN RETURNING REVOKE "
"ROLE ROLES ROLLBACK ROW ROWS SAVEPOINT SCHEMA SCOPE SELF SEMI SEQUENCE"
" SET SHOW SOME START STATISTICS STRING SYSTEM TIES TO TRAN TRANSACTION TRIGGER TRUNCATE UNBOUNDED UNDER "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove SET TRANSACTION

Comment on lines +402 to +415
const char* p = kServerReservedWords;
const char* start = nullptr;
for ( ; *p != '\0'; ++p ) {
if ( *p == ' ' ) {
if ( start != nullptr ) {
//start -> p
serverReserved.emplace(start, p);
start = nullptr;
}
} else if ( start == nullptr ) {
start = p;
}
}
if ( start != nullptr ) { serverReserved.emplace(start, p); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use split() for this instead of nasty C code:

    /** Splits the string at occurrences of `separator` and calls the callback for each piece.
        There may be empty pieces, if the separator occurs at the start or end or twice in a row. */
    void split(std::string_view str, std::string_view separator, fleece::function_ref<void(std::string_view)> callback);

You'll need a consistent delimiter between words though, probably a single space.

static bool isServerReservedWord(std::string word);

static string warnOnServerReservedWord(const char* input) {
if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in the Server SQL++)", input); }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in the Server SQL++)", input); }
if ( isServerReservedWord(input) ) { Warn(R"("%s" is a reserved word in Server SQL++)", input); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants